<?php
include_once $_SERVER['DOCUMENT_ROOT']."/functions/bdd/photos/principale.php";

function afficheResults($reponse) {
    $nb_reponses = 0;

    while ($donnees = $reponse->fetch()) {
        $nb_reponses++;
        ?>
        <div class = "underline">
            <h3>
                <a href="aff_details.php?id=<?php echo $donnees['id']; ?>">
                    <?php echo $donnees['nom']; ?>
                </a>
            </h3>
			<img src="<?php echo get_photo_principale($donnees['id']);?>" alt="avion" style="float:right" width="160" />
            <p class="description_avion">
                <?php echo $donnees['description']; ?>
            </p>


            <p>
                <span class="label">Stabilité : </span>
                <?php
                for ($i = 0; $i < $donnees['stabilite']; $i++) {
                    ?>
                    <img src = "/images/etoiles/star_on.png" alt = 1/>
                    <?php
                }
                for ($i = 0; $i < 5 - $donnees['stabilite']; $i++) {
                    ?>
                    <img src = "/images/etoiles/star_off.png" alt = 1/>
                    <?php
                }
                ?>
                <br/>
                <span class="label">Difficulté : </span>
                <?php
                for ($i = 0; $i < $donnees['difficulte']; $i++) {
                    ?>
                    <img src = "/images/etoiles/star_on.png" alt = 1/>
                    <?php
                }
                for ($i = 0; $i < 5 - $donnees['difficulte']; $i++) {
                    ?>
                    <img src = "/images/etoiles/star_off.png" alt = 1/>
                    <?php
                }
                ?>
                <br/>
                <span class="label">Stabilité au tangage : </span>
                <?php
                for ($i = 0; $i < $donnees['stab_tang']; $i++) {
                    ?>
                    <img src = "/images/etoiles/star_on.png" alt = 1/>
                    <?php
                }
                for ($i = 0; $i < 5 - $donnees['stab_tang']; $i++) {
                    ?>
                    <img src = "/images/etoiles/star_off.png" alt = 1/>
                    <?php
                }
                ?>
                <br/>
                <span class="label">Stabilité au roulis : </span>
                <?php
                for ($i = 0; $i < $donnees['stab_roul']; $i++) {
                    ?>
                    <img src = "/images/etoiles/star_on.png" alt = 1/>
                    <?php
                }
                for ($i = 0; $i < 5 - $donnees['stab_roul']; $i++) {
                    ?>
                    <img src = "/images/etoiles/star_off.png" alt = 1/>
                    <?php
                }
                ?>
                <br/>
                <span class="label">Vitesse d'évolution : </span>
                <?php
                echo $donnees['vitesse'];
                ?>
                <br/>
                <span class="label">Vitesse de décrochage : </span>
                <?php
                echo $donnees['decrochage'];
                ?>
            </p>


        </table>
        </div>
        <?php
    }

    if (!($nb_reponses)) {
        ?>
        <div class = "underline">
            <p>
                Votre recherche n'a donné aucun résultat
            </p>
        </div>
        <?php
    }
}
?>
